import java.util.HashMap;
import java.util.Map;

public class 对于给定的n个位于同一二维平面上的点求最多能有多少个点位于同一直线上 {
    
    public static void main(String[] args) {
        
        Point[] points = new Point[]{new Point(2,3), new Point(3,3), new Point(-5,3)};

        System.out.println(maxPoints(points));

    }

    public static int maxPoints(Point[] points) {
        if (points.length <= 2) {
            return points.length;
        }
        int maxCount = 0;
        for (int i = 0; i < points.length; i++) {
            Map<String, Integer> slopes = new HashMap<>();
            int samePoints = 0;
            int localMax = 0;
            for (int j = i + 1; j < points.length; j++) {
                if (points[i].x == points[j].x && points[i].y == points[j].y) {
                    samePoints++;
                    continue;
                }
                int dx = points[j].x - points[i].x;
                int dy = points[j].y - points[i].y;
                int gcd = gcd(dx, dy);
                if (gcd!= 0) {
                    dx /= gcd;
                    dy /= gcd;
                }
                String key = dx + "/" + dy;
                slopes.put(key, slopes.getOrDefault(key, 0) + 1);
                localMax = Math.max(localMax, slopes.get(key));
            }
            maxCount = Math.max(maxCount, localMax + samePoints + 1);
        }
        return maxCount;
    }

    private static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    private static class Point {
        int x;
        int y;
        Point() { x = 0; y = 0; }
        Point(int a, int b) { x = a; y = b; }
    }    
}
